package com.atguigu.service.impl;

import com.atguigu.mapper.EmployeeMapper;
import com.atguigu.pojo.Employee;
import com.atguigu.service.EmployeeService;
//import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

/**
 * @author Chunsheng Zhang 尚硅谷
 * @create 2022/5/4 15:40
 */
@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    @Qualifier("employeeMapper")
    private EmployeeMapper employeeMapper;

    @Autowired
    private JedisPool jedisPool;



    private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeServiceImpl.class);
    @Override
    @Transactional(propagation = Propagation.REQUIRED,
            isolation = Isolation.READ_COMMITTED)
    public List<Employee> getAllEmps() {
        List<Employee> employees = employeeMapper.selectAllEmps();
        System.out.println("employees = " + employees);
        LOGGER.info("hello");
        return employees;
    }

    @Override
    public void method() {
        System.out.println("employeeMapper = " + employeeMapper);
        Jedis jedis = jedisPool.getResource();
        System.out.println("jedis = " + jedis);
        String s = jedis.get("num");
        System.out.println("s = " + s);
    }
}
